package main

import "fmt"
// import "os"
import "database/sql"
// import "github.com/ziutek/mymysql/mysql"
// import _ "github.com/ziutek/mymysql/native"

import _ "code.google.com/p/go-mysql-driver/mysql"


func main() {
    fmt.Println("LO, World")
    // db := mysql.New("tcp", "", "127.0.0.1:3306", "eh", "squonkbite", "summarise")
    db, err := sql.Open("mysql", "eh:squonkbite@/summarise?charset=utf8" )

    // err := db.Connect()
    demand(err)
    rows, err := db.Query("show tables")
    demand(err)
    for rows.Next() {
        cols, err := rows.Columns()
        places := make([]interface{}, len(cols))
        for i := range places { places[i] = new([]byte) }
        err = rows.Scan(places...)
        demand(err)
        for _, x := range places { fmt.Println(string(*x.(*[]byte))) }
    }
}

//func columns(db *sql.DB, table string) {
//    rows, err := db.Query("show columns from " + table)
//    demand(err)
//    for _, row := range rows {
//        for _, col := range row {
//            if col == nil { 
//                fmt.Print( " nil" )
//            } else {
//                fmt.Print(" ", string(col.([]byte)))
//            }
//        }
//        fmt.Println()
//    }
//}
//
//
func demand(err error) {
    if err != nil { panic( err ) }
}
